package ${package}.${moduleName}.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import ${package}.${moduleName}.domain.entity.${ClassName}Entity;
import ${package}.${moduleName}.service.${serviceClassName}Service;
import ${package}.${moduleName}.domain.query.${ClassName}Query;
import ${package}.${moduleName}.domain.vo.${ClassName}VO;
import ${package}.${moduleName}.domain.form.${ClassName}Form;
import ${package}.mybatisplus.domain.vo.BasePageVO;

/**
* ${tableComment}
*
* @author ${author}
* @datetime ${datetime}
*/
@Slf4j
@RestController
@RequestMapping("${urlPath}")
@RequiredArgsConstructor
public class ${ClassName}Controller {

    private final ${serviceClassName}Service ${className}Service;

    /**
     * 分页数据
     * @param ${className}Query 查询对象
     * @return 分页数据
     */
    @GetMapping("page")
    public BasePageVO<${ClassName}VO> page(@Valid ${ClassName}Query ${className}Query){
        return ${className}Service.page(${className}Query);
    }

    <#-- 只有设置了主键类型, 才会生成 getInfoById 方法 -->
    <#if pkType??>
    /**
     * 根据 ID 获取数据
     * @param id ID
     * @return 数据信息
     */
    @GetMapping("{id}")
    public ${ClassName}VO get(@PathVariable("id") ${pkType} id){
        return ${className}Service.getInfoById(id);
    }
    </#if>

    /**
     * 保存数据
     * @param ${className}Form 表单信息
     * @return true: 新增成功; false: 新增失败
     */
    @PostMapping
    public boolean save(@Valid ${ClassName}Form ${className}Form){
        return ${className}Service.save(${className}Form);
    }

    /**
     * 修改数据
     * @param ${className}Form 表单信息
     * @return true: 修改成功; false: 修改失败
     */
    @PutMapping
    public boolean update(@Valid ${ClassName}Form ${className}Form){
        return ${className}Service.update(${className}Form);
    }

    /**
     * 删除修改数据
     * @param ids id 列表
     * @return true: 删除成功; false: 删除失败
     */
    @DeleteMapping
    public boolean delete(@RequestParam("ids") String ids){
        return ${className}Service.deleteByIds(ids);
    }
}